home *** CD-ROM | disk | FTP | other *** search
/ Zoom 2 / Zoom - Release 2 (1996)(Active Software)[!].iso / programming / basic / ace / utils / a-a / a-a.doc / text0000.txt < prev   
Encoding:
Text File  |  1994-10-22  |  11.3 KB  |  240 lines

  1.                             AMOS to ACE
  2.                             Version 1.0
  3.                            June 22, 1993
  4.  
  5. INTRODUCTION
  6. ------------
  7.   This program is intended for people like me: people who have a
  8. big, bulky application program written in AMOS BASIC. AMOS is nice
  9. for development, because it's interpreted, and runs fast. But
  10. programs written in it have a lot of problems - such as opening up
  11. their own screen (which is not Intuition-compatible), not
  12. multitasking with each other, and not working properly with the
  13. 68040. This makes AMOS programs murder to run for any serious
  14. computer user - and most of them won't.
  15.   ACE has its own set of problems, but most of them are compiler
  16. limitations. They're not things that would affect the end user of
  17. the application program. When you're writing programs for fame,
  18. instead of fortune, that's an important consideration.
  19.   AMOS and ACE are not completely compatible. Most of the commands
  20. found in ACE are in AMOS, but some of them have the parameters in a
  21. different order. There are a few cases where both programs have the
  22. same function, but require a different command to execute it. This
  23. can make converting from one to the other rather tedious - and once
  24. you do, you have to either drop the original version, or (try) to
  25. develop them both in parallel.
  26.   AMOS to ACE is designed to help. With it, you can keep one version
  27. of your program (in AMOS format) and convert it to ACE when you're
  28. ready to compile it. It has quite a few limitations, and can't
  29. convert anywhere near all of AMOS's command set (most of them have
  30. no analogues in ACE), but should be very useful to serious
  31. developers (who don't want to admit that they're writing programs in
  32. AMOS). The program is user-extensible, and enough information is
  33. provided in this documentation to allow interested users to
  34. customize the program.
  35.  
  36. SUPPORTED CONVERSIONS
  37. ---------------------
  38. X, Y, A$, B$, ect. represent the positions of variables in commands.
  39.  
  40. AMOS VERSION                            ACE VERSION
  41. Inc X                                   ++X
  42. Dec X                                   --X
  43. Add X,Y-Z                               X=X+Y-Z
  44. Free                                    FRE(-1)
  45. Instr(A$,B$,X)                          INSTR(X,A$,B$)
  46. Upper$(A$)                              UCASE$(A$)
  47. End If                                  END IF
  48. If(X=Y)                                 IF (X=Y) THEN
  49. Do                                      REPEAT
  50. Loop                                    UNTIL 1=0
  51. Rnd(X)                                  RND
  52. Fix(A)                                  FIX A+1
  53. Say "hello",1                           SAY "hello"
  54. Open Out 1,"out_file"                   OPEN "O",#1,"out_file"
  55. Open In 1,"junk_file"                   OPEN "I",#1,"junk_file"
  56. Append 1,"my_foo_bar"                   OPEN "A",#1,"my_foo_bar"
  57. Hex$(X,Y)                               HEX$(X)
  58. Bin$(X,Y)                               BIN$(X)
  59. Deek(A)                                 PEEKW(A)
  60. Doke A,Y                                POKEW A,Y
  61. Leek(A)                                 PEEKL(A)
  62. Loke A,Y                                POKEL A,Y
  63. Procedure HELLO[X,Y,Z]                  SUB HELLO(X,Y,Z)
  64. Procedure HELLO                         SUB HELLO
  65. End Proc                                END SUB
  66. Proc HELLO[X,Y,Z]                       CALL HELLO(X,Y,Z)
  67. Proc HELLO                              CALL HELLO
  68. Set Buffer 100                          <blank line>
  69. String$(A$,X)                           STRING$(X,A$)
  70. Rename "hello" To "goodbye"             NAME "hello" AS "goodbye"
  71. Lower$(A$)                              LCASE$(A$)
  72.  
  73.   Note that the LCASE$ function is not part of ACE's command set. It
  74. is found in <strings.h> and must be included.
  75.   Although a version of the MID$ command, with different syntax, is
  76. also in <strings.h>, A-A does not convert to it from AMOS. AMOS's
  77. version of the MID$ command has a serious bug, and should never be
  78. used. (Note that AMOS's MID$ FUNCTION works properly)
  79.   I've been told that in a recent version of AMOS Pro the MID$
  80. command bug has finally been found and corrected, but in all prior
  81. versions (and in all versions of the original AMOS) the bug still
  82. exists.
  83.  
  84. HOW IT WORKS
  85. ------------
  86.   A-A works by comparing each program line against several dozen
  87. internal templates. If a match is found, the "corrected" version of
  88. the match is output. If not, the first character of the line is
  89. deleted from the internal buffer and output to the destination file,
  90. and the process begins again. A typical template looks like this:
  91.  
  92. CONVANYFROM$(11)="Rnd(\1)"+Chr$(10)
  93.  
  94.   The "R", "n", "d" and left parenthesis characters are "constants" -
  95. if they don't match with the input line, the comparison immediately
  96. fails. The backslash is special - it is the "variable" character.
  97. A-A has nine internal "variables" which it uses to rearrange parts
  98. of the input line. The backslash must be followed immediately by the
  99. variable number, and then by the "success-character" and the
  100. "failure-character". When A-A sees the backslash, it scans through
  101. the input line, looking for both the success and failure characters.
  102. If the failure-character appears before the success-character, or
  103. the success-character does not appear at all, the match fails.
  104.   Otherwise, the input line, up to the point that the
  105. success-character was found, is placed in the specified "variable",
  106. and A-A continues comparing the template against the input line,
  107. starting from the position right after where the success-character
  108. was found. Notice that the success-character in the example is a
  109. right parenthesis, and the failure-character is a linefeed (the
  110. Amiga's end-of-line character).
  111.   If any match fails, all variables are cleared before the input
  112. line is compared against the next template. Also, if the same
  113. variable appears multiple times in a template, the appropriate
  114. section of the input line is added onto the existing contents of the
  115. variable.
  116.   If a template matches completely, a definition such as this is
  117. used to determine what to output:
  118.  
  119. CONVANYTO$(11)="RND"
  120.  
  121.   All characters specified, except for the backslash character, are
  122. output verbatim. Again, the backslash character is special - it is
  123. followed immediately by a variable number, and the contents of that
  124. variable are inserted into that position in the output. In the
  125. example, the contents of the variable have been discarded - ACE's
  126. version of the Random function does not take a parameter.
  127.   There are two kinds of templates in A-A.  The ones in the arrays
  128. beginning with CONVBEGIN are checked against the input line only
  129. once, starting with the first character. This is because certain
  130. commands (such as IF) can only legally appear at the beginning of
  131. the line, and so it is not necessary to check for them across the
  132. entire line. Commands in the arrays beginning with CONVANY (such as
  133. the Instr function) can appear at any place in the input line, and
  134. so are checked for at every position.
  135.   The template conversion method has some problems. The worst of
  136. them appears in connection with strings. If A-A sees the input line
  137.  
  138. PRINT "Let Freedom Ring"
  139.  
  140. it will erroneously convert the Free in Freedom to FRE(-1).
  141.   Another problem occurs because of AMOS's IF statements. There are
  142. actually two versions of the IF statement in AMOS - one that has a
  143. "then" and one that does not. The scope of the "then" version is
  144. limited to the current line; the other version must be terminated
  145. with an END IF. A-A will always add a THEN onto the end of an IF;
  146. this will cause ACE to generate an error if there was already a THEN
  147. there. Fortunately, though, AMOS has an odd restriction about the
  148. "then" version - it can't be used if you're already inside an IF (of
  149. either kind). Thus I never use the "then" version, because I would
  150. have to rewrite it if I ever put another IF around that block of
  151. code. Hopefully, most other AMOS users think the same way.
  152.   A third problem occurs because the conversion routines are not
  153. recursive. If A-A converts an IF statement, it will not convert the
  154. statement's parameters.
  155.   A-A does have one "special case" patch - if the success-character
  156. in a variable is a right parenthesis, A-A will keep track of the
  157. number of left and right parentheses it encounters in the input
  158. line, and not match with any nested right parentheses.
  159.   These problems, and others, can be solved (with some annoyance) by
  160. using the conditional conversion feature.
  161.  
  162. CONDITIONAL CONVERSION
  163. ----------------------
  164.   Sections of code can be designated as AMOS-only or ACE-only. This
  165. is done in the following way:
  166.  
  167. Rem Begin AMOS
  168.       ...
  169. <AMOS-only code>
  170.       ...
  171. Rem End AMOS
  172.  
  173. Rem ACE      ...
  174. Rem ACE <ACE-only code>
  175. Rem ACE      ...
  176.  
  177.   Note that these Rem statements must be typed EXACTLY as shown.
  178.   When A-A sees the text "Rem Begin AMOS", it will discard all lines
  179. after that until it sees the text "Rem End AMOS". It will then place
  180. "Rem AMOS" into the output stream to mark the place (in case you
  181. want to look at the output file) and continue as normal.
  182.   When A-A sees the text "Rem ACE", it will strip it out and place
  183. the remainder of the line into the output stream, without performing
  184. any conversions. It will then continue as normal.
  185.   Although this feature was mainly intended to allow you to replace
  186. AMOS commands (particularly graphic-oriented ones) with ones that
  187. will work under ACE, it can also be used to get around the template
  188. converter's limitations. Make a copy of the "problem" line, manually
  189. do whatever conversions are necessary, and designate the old and new
  190. lines as AMOS- and ACE-only, respectively.
  191.   Making use of this feature will affect the size of your source
  192. code and (marginally) the speed of your interpreted program. It will
  193. not affect the final compile, because only the ACE sections will get
  194. to the compiler.
  195.  
  196. VARIABLE TYPE DIFFERENCES
  197. -------------------------
  198.   AMOS has two kinds of numeric variables: integers (4 bytes) which
  199. do not have a qualifier, and floating-point variables (4 bytes),
  200. which have a "#" as a qualifier. ACE has four kinds: short integer
  201. (2 bytes, "%" qualifier), long integer (4 bytes, "&"),
  202. single-precision (4 bytes, "!"), and double-precision (8 bytes,
  203. "#").
  204.   In AMOS, if no qualifier is appended to a variable name, it is
  205. treated as an integer. In ACE it's treated as single-precision.
  206. This isn't a problem because A-A automatically puts a DEFLNG a-z
  207. directive at the beginning of the output file, which makes all
  208. integers the same length as AMOS.
  209.   The difference is with the floating-point variables. In AMOS, a
  210. 4-byte float has a trailing hash character; in ACE it has a trailing
  211. exclamation point. The easiest course is simply to leave the
  212. variable alone; ACE will just see it as a variable of greater
  213. precision than it originally was. This should cause no problems (I
  214. hope).
  215.   At the moment, double-precision variables aren't implemented in
  216. ACE - they're treated by the compiler as single-precision. So, for
  217. now, there is no potential incompatibility problem.
  218.  
  219. OTHER STUFF
  220. -----------
  221.   There are two extra subroutines in A-A called BEFORECHECK and
  222. AFTERCHECK. These are called on each character "step" through the
  223. input line, before and after (respectively) the line is compared
  224. against the templates. At the moment, BEFORECHECK is being used only
  225. to implement the conditional conversion feature, and AFTERCHECK is
  226. blank. You can place extra code in the subroutines to make A-A
  227. handle your specific personal requirements.
  228.  
  229.  
  230.  
  231. Interested parties can contact me at:
  232.  
  233. Roland Acton
  234. 8001 Bluebird Lane
  235. La Palma, CA, 90623
  236. U.S.A.
  237.  
  238. Internet: xracton@ccvax.fullerton.edu
  239.  
  240.